home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part2 / 11835 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.3 KB

  1. Path: news.image.dk!usenet
  2. From: Poul Thomas Lomholt <davinci@image.dk>
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: static and dynamic classes in C++ ?
  5. Date: Sat, 16 Mar 1996 15:36:41 +0100
  6. Organization: Da Vinci Data
  7. Message-ID: <314AD1F9.37A0@image.dk>
  8. References: <3148472F.41C6@informatik.uni-siegen.de>
  9. NNTP-Posting-Host: ip102.image.dk
  10. Mime-Version: 1.0
  11. Content-Type: text/plain; charset=us-ascii
  12. Content-Transfer-Encoding: 7bit
  13. X-Mailer: Mozilla 2.0 (WinNT; I)
  14.  
  15. Runu Knips wrote:
  16. > Hi people!
  17. > 1. Is it possible to declare a class in a way that only
  18. > dynamic instances of it may be declared ?
  19. > 2. Is it also possible to declare a class in a way that
  20. > only static (i.e. stack or data segment) instances may
  21. > be declared ?
  22. > Thanx you in advance for any answer :)
  23. > Ciao
  24.  
  25.  
  26. Answ 1: Yes, make the destructor private, and use a "destroy" 
  27. function (meking a "delete this") that must be called 
  28. explicitly. This effectively stops any stack objects, because 
  29. their destructor, if any, allways must be called when the object 
  30. goes out of scope!
  31.  
  32. For the answer on your second question I suggest you get the 
  33. "More Effective C++", written by Scott Meyers. I know there is 
  34. some information on these topics. I rememebered the first one, 
  35. but not your second question!
  36.  
  37. Ciao ciao 
  38. Poul Thomas Lomholt
  39.